package com.gyg.controller;


import com.gyg.returns.RespEntity;
import com.gyg.service.CloudTrashService;
import com.gyg.vo.param.TrashParam;
import com.gyg.vo.result.RecordListResult;
import com.gyg.vo.result.TrashListResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 文件回收表 前端控制器
 * </p>
 *
 * @author gyg
 * @since 2021-04-14
 */
@RestController
@RequestMapping("/cloud-trash")
@Slf4j
@Api(value = "文件回收站", tags = "文件回收站")
public class CloudTrashController {

    @Resource
    private CloudTrashService cloudTrashService;

    @ApiOperation(value = "回收站列表")
    @GetMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "userId", value = "用户id", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "pageNum", value = "当前页数", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "pageSize", value = "每页数量", required = true)
    })
    public RespEntity<TrashListResult> cloudTrashList(@RequestParam(value = "userId", required = true) Integer userId,
                                                      @RequestParam(value = "pageNum", required = true) Integer pageNum,
                                                      @RequestParam(value = "pageSize", required = true) Integer pageSize) {
        RespEntity<TrashListResult> respEntity = cloudTrashService.cloudTrashList(userId, pageNum, pageSize);
        return respEntity;
    }

    @PutMapping("/recover")
    @ApiOperation(value = "恢复")
    public RespEntity recoverTrash(@RequestBody TrashParam trashParam) {
        RespEntity respEntity = cloudTrashService.recoverTrash(trashParam);
        return respEntity;
    }

    @DeleteMapping("/delete")
    @ApiOperation(value = "彻底删除")
    public RespEntity deleteTrash(@RequestBody TrashParam trashParam) {
        RespEntity respEntity = cloudTrashService.deleteTrash(trashParam);
        return respEntity;
    }

}
